<?php
require_once 'log/Logger.php';
$con = mysql_connect('localhost','qqxj','qqxj');
$rs = mysql_select_db('botlog', $con);
mysql_query("SET NAMES 'GBK'");

//查出运行帐户
$curtime = time();
$daysums = array();
$presummoney = 0;
$daysums = array();
for($i = 1;$i <= 7;$i++)
{
    
    $day = date("Ymd",$curtime);
    $query = "select max(money) as money from {$day}_botlog group by rolename";
    
    $rs = mysql_query($query, $con);
    
    if(!$rs)
        continue;
    
    //Logger::getLogger()->debug($query."\n");
    $ar = mysql_fetch_array($rs);
    $daysum = array();
    $daysum['sum'] = 0;
    $daysum['day'] = $day;
    $daysum['rolecount'] = mysql_num_rows($rs);
    $daysum['addsum'] = 0;
    while($ar)
    {
        $daysum['sum'] = $daysum['sum'] + $ar['money'];
        $ar = mysql_fetch_array($rs);
    }
    
    $daysums[] = $daysum;
    $curtime = $curtime - 3600 * 24;
}




echo "var sumday = ".json_encode($daysums);


mysql_close($con);
?>
